package com.qf.fengmimall.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.fengmimall.user.entity.UserAddr;
import com.qf.fengmimall.user.service.IUserAddrService;
import com.qf.fengmimall.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 刘欣
 * @createTime 2023/2/16 23:23
 * @description
 */
@RestController
@RequestMapping("/useraddr")
@CrossOrigin
@Slf4j
public class UserAddrController {

    @Autowired
    private IUserAddrService userAddrService;

    /**
     * 获取用户信息
     *
     * @param userId
     * @return
     */
    @RequestMapping("/list")
    public ResultVo userAddrList(String userId) {
        log.debug("接受到的参数为userId={0}", userId);
        List<UserAddr> userAddrs = userAddrService.list(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
        return ResultVo.ok(userAddrs);
    }
}
